package diagramobjects;

import java.awt.Graphics;

import program.PaintObjects;

public class SelectionRect
{
	private Integer x;
	private Integer y;
	private Integer w;
	private Integer h;
	
	public SelectionRect()
	{
		x = 0;
		y = 0;
		w = 0;
		h = 0;
	}

	public SelectionRect(Integer x, Integer y, Integer w, Integer h)
	{
		this.x = x;
		this.y = y;
		this.w = w;
		this.h = h;
	}
	
	public void SetSelection(Integer x, Integer y, Integer w, Integer h)
	{
		if (w < 0)
		{
			this.x = x + w;
			this.w = -w;
		}
		else
		{
			this.x = x;
			this.w = w;
		}
		
		if (h < 0)
		{
			this.y = y + h;
			this.h = -h;
		}
		else
		{
			this.y = y;
			this.h = h;
		}
		
		System.out.println("pOPRAWIANE SR: X: " + getX() + " Y: " + getY() + " W: " + getW() + " H:" + getH());
	}
	
	public void Reset()
	{
		x = 0;
		y = 0;
		w = 0;
		h = 0;
	}

	public Integer getX()
	{
		return x;
	}

	public void setX(Integer x)
	{
		this.x = x;
	}

	public Integer getY()
	{
		return y;
	}

	public void setY(Integer y)
	{
		this.y = y;
	}

	public Integer getW()
	{
		return w;
	}

	public void setW(Integer w)
	{
		this.w = w;
	}

	public Integer getH()
	{
		return h;
	}

	public void setH(Integer h)
	{
		this.h = h;
	}
	
	public void Draw(Graphics g, PaintObjects po)
	{
		po.DrawSelectionRect(g , this);
	}
	
}
